//
//  TodayHeaderView.m
//  YiTangZuoWenKe_tec
//
//  Created by Work on 2017/8/17.
//  Copyright © 2017年 王雅鹏. All rights reserved.
//首页公告资讯View

#import "TodayHeaderView.h"
#import "XLsn0wTextCarousel.h"
#import "DataSourceModel.h"
#import "BYHomeInfoCarouselModel.h"//首页资讯轮播的model


@interface TodayHeaderView()<TextInfoViewDelegate>
/**两行跑马灯的View*/
@property(nonatomic,strong)XLsn0wTextCarousel *textCarouselView;

@end
@implementation TodayHeaderView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubView];
    }
    return self;
}
- (void)addSubView{
     self.backgroundColor = [UIColor whiteColor];
    //公告资讯
    UIImageView *noticeImgView = [[BYViewSingle shareBYViewSingle]createImgView:@"homeNotice_title" addSubView:self];
    noticeImgView.frame = CGRectMake(BY_Width(24), BY_Height(34), BY_Height(64), BY_Height(64));
    //跑马灯
    _textCarouselView = [[XLsn0wTextCarousel alloc] initWithFrame:CGRectMake(BY_Width(24+12)+BY_Height(64), BY_Height(20), BY_ScreenWidth - BY_Width(24+12+24+12) - BY_Height(64), BY_Height(92))];
    _textCarouselView.currentTextInfoView.xlsn0wDelegate = self;
    _textCarouselView.hiddenTextInfoView.xlsn0wDelegate = self;
    _textCarouselView.backgroundColor =[UIColor whiteColor];
    [self addSubview:_textCarouselView];
    //下划线
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, BY_Height(92+20*2), BY_ScreenWidth, BY_Height(9))];
    lineView.backgroundColor = RGBA(225, 225, 225, 1.0);
    [self addSubview:lineView];
}
- (void)setDataArr:(NSArray *)dataArr{
    
    
    for (BYSetModel *models in APPDELEGATE.SetDataArray) {
        if ([models.setting_name isEqualToString:@"main-notice-block-link"]) {
            _dataArr = dataArr;
            NSMutableArray *arrM = [NSMutableArray array];
            for (BYHomeInfoCarouselModel *infoCarModel in _dataArr) {
                DataSourceModel *model = [DataSourceModel dataSourceModelWithType:@"" title:infoCarModel.title URLString:models.setting_value];
                [arrM addObject:model];
            }
            _textCarouselView.dataSourceArray = arrM;
        }
    }
}
- (void)handleTopEventWithURLString:(NSString *)URLString {
//    NSLog(@"点击了上方的url===%@", URLString);
    if (self.clickHorseRaceLampRow) {
        self.clickHorseRaceLampRow(URLString);
    }
}
- (void)handleBottomEventWithURLString:(NSString *)URLString {
//    NSLog(@"点击了下方的url===%@", URLString);
    if (self.clickHorseRaceLampRow) {
        self.clickHorseRaceLampRow(URLString);
    }
}
- (void)getTopDataSourceModel:(DataSourceModel *)topDataSourceModel {
//    NSLog(@"第一个 %@ %@ %@", topDataSourceModel.type, topDataSourceModel.title, topDataSourceModel.URLString);
}
- (void)getBottomDataSourceModel:(DataSourceModel *)bottomDataSourceModel {
//    NSLog(@"第二个 %@ %@ %@", bottomDataSourceModel.type, bottomDataSourceModel.title, bottomDataSourceModel.URLString);
}


@end
